package com.ty.controller;

import com.ty.pojo.OddMeet;
import com.ty.service.OddMeetService;
import com.ty.vo.PageResult;
import com.ty.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.w3c.dom.stylesheets.LinkStyle;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.List;

@RestController
@CrossOrigin
@EnableSwagger2
@RequestMapping("/oddmeet")
public class OddMeetController {
    @Autowired
    private OddMeetService oddMeetService;
    //查询奇遇表
    @GetMapping("/getOddMeetList")
    public SysResult getOddMeetList(@RequestBody PageResult pageResult,OddMeet oddMeet){
        pageResult = oddMeetService.getOddMeetList(pageResult,oddMeet);
        return SysResult.success(pageResult);
    }
    //新增奇遇
    @PostMapping("/addOddMeet")
    @Transactional
    public SysResult addOddMeet(@RequestBody OddMeet oddMeet){
        oddMeetService.addOddMeet(oddMeet);
        return SysResult.success();
    }
    //修改奇遇
    @PutMapping("/updateOddMeet")
    @Transactional
    public SysResult updateOddMeet(@RequestBody OddMeet oddMeet){
        oddMeetService.updateOddMeet(oddMeet);
        return SysResult.success();
    }
    //修改奇遇状态,伪删除
    @PutMapping("/updateState/{id}")
    @Transactional
    public SysResult updateState(@PathVariable Integer id){
        oddMeetService.updateState(id);
        return SysResult.success();
    }
}
